<template>
  <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="权限策略详情" width="750px">
    <Description :data="detailData" @register="registerDescription" />
  </BasicDrawer>
</template>
<script lang="ts" setup>
import { ref, useAttrs } from 'vue';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { formDetailSchema } from './data';
import { Description, useDescription } from '/@/components/Description/index';
import * as permPolicyApi from '/@/api/iam/permPolicy';
const emit = defineEmits(['register']);
const attrs = useAttrs();
const detailData = ref({});
const [registerDescription] = useDescription({
  schema: formDetailSchema,
  column: 2,
  bordered: false,
  labelStyle: {
    marginLeft: '10px'
  }
});

const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
  setDrawerProps({confirmLoading: false, loading: true})
  try {
    detailData.value = await permPolicyApi.getPermissionPolicy({id: data.record.id, apiNamespaceCode: data.apiNamespaceCode})
  } finally {
    setDrawerProps({ loading: false })
  }
});
</script>
